package com.rcn.core;

import com.google.common.base.Strings;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.MappedSuperclass;

/**
 *
 * @author Nicolas
 */
@MappedSuperclass
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public abstract class Person {
    private String name;
    private String surname;

    /**
     * @return the name
     */
    @Basic
    @Column(name = "name")
    public String getName() {
        return name;
    }

    /**
     * @param nombre the name to set
     */
    public void setName(String name) {
        if(Strings.isNullOrEmpty(name)){
            throw new IllegalArgumentException("El nombre del paciente debe completarse.");
        }
        this.name = name;
    }

    /**
     * @return the apellido
     */
    @Basic
    @Column(name = "surname")
    public String getSurname() {
        return surname;
    }

    /**
     * @param surname the surname to set
     */
    public void setSurname(String surname) {
        if(Strings.isNullOrEmpty(surname)){
            throw new IllegalArgumentException("El apellido del paciente debe completarse.");
        }
        this.surname = surname;
    }
    
    @Override
    public String toString()
    {
    	return this.getSurname() + " " +this.getName();
    }
}
